<template>
    <div class="orderInfo">
        <div class="back">
            <a-button @click="$router.push({ name: 'OrderReturnsExchangeManagement' })">返回</a-button>
        </div>
        <!-- 进度条 -->
        <div class="speedProgress">
            <a-steps :current="stepNum" labelPlacement="vertical" size="small" v-if="repairsLogs.length>0">
                <a-step>
                    <span slot="title">客户申请换货</span>
                    <span slot="description" >{{repairsLogs[0].createDate || ''}}</span>
                </a-step>
                <a-step>
                    <span slot="title">待审核</span>
                    <span slot="description">{{repairsLogs[0].createDate || ''}}</span>
                </a-step>
                <a-step>
                    <template v-if="applyStatus==='REVIEW_FAILED' ">
                        <span slot="title">审核意见</span>
                        <p slot="description" v-if="stepNum===3 ">审核人：{{ handler}}</p>
                        <p slot="description" v-if="stepNum===3 ">拒绝换货</p>
                        <p slot="description" v-if="stepNum===3 ">已经和买家协商</p>
                        <p slot="description" v-if="stepNum===3 ">{{repairsLogs[1].createDate || ''}}</p>
                    </template>

                    <template v-else-if="applyStatus==='USER_CANCEL'">
                        <span slot="title">已撤销申请</span>
                        <!--                        <p slot="description" v-if="stepNum>=3 ||applyStatus==='BUYER_SEND_BACK'">审核人：{{ handler}}</p>-->
                        <!--                        <p slot="description" v-if="stepNum>=3 ||applyStatus==='BUYER_SEND_BACK'">同意换货</p>-->
                        <p slot="description" v-if="stepNum===2">{{repairsLogs[2].createDate || ''}}</p>
                    </template>

                    <template v-else>
                        <span slot="title">审核意见</span>
                        <p slot="description" v-if="stepNum>=3 ||applyStatus==='APPROVE_AUDIT'">审核人：{{ handler}}</p>
                        <p slot="description" v-if="stepNum>=3 ||applyStatus==='APPROVE_AUDIT'">同意换货</p>
                        <p slot="description" v-if="stepNum>=3 ||applyStatus==='APPROVE_AUDIT'">{{repairsLogs[1].createDate || ''}}</p>
                    </template>
                </a-step>
                <a-step v-if="applyStatus!=='REVIEW_FAILED' && applyStatus!=='USER_CANCEL'  ">
                    <span slot="title">寄回中</span>
                    <p slot="description" v-if="stepNum>=3 && !!expressCompanyName" >物流快递：{{expressCompanyName}}</p>
                    <p slot="description" v-if="stepNum>=3 && !!expressCompanyName" >快递单号：{{expressTrackNumber}}</p>
                    <p slot="description" v-if="stepNum>=4" >{{repairsLogs[2].createDate || ''}}</p>
                </a-step>

                <a-step v-if="applyStatus!=='REVIEW_FAILED' && applyStatus!=='USER_CANCEL' ">
                    <span slot="title">确认收货</span>
                    <p slot="description" v-if="stepNum>=5" >确认人：{{handler}}</p>
                    <p slot="description" v-if="stepNum>=5" >收货备注：{{shouhuoexplanation}}</p>
                    <p slot="description" v-if="stepNum>=5" >{{repairsLogs[3].createDate || ''}}</p>
                </a-step>
                <a-step v-if="applyStatus!=='REVIEW_FAILED'  && applyStatus!=='USER_CANCEL' ">
                    <span slot="title">重新发货</span>
                    <p slot="description" v-if="stepNum>=6 || applyStatus==='AGAIN_DELIVER_GOODS'">确认人：{{handler}}</p>
                    <p slot="description" v-if="stepNum>=6 || applyStatus==='AGAIN_DELIVER_GOODS'">发货备注：{{fahuoexplanation}}</p>
                    <p slot="description" v-if="stepNum>=6 || applyStatus==='AGAIN_DELIVER_GOODS'">{{repairsLogs[4].createDate|| ''}}</p>
                </a-step>
                <a-step v-if="applyStatus!=='REVIEW_FAILED'  && applyStatus!=='USER_CANCEL' ">

                    <span slot="title" v-if="applyStatus==='EXCHANGE_GOODS_FINISH'">换货成功</span>
                    <span slot="title" v-else>等待买家收货</span>
                    <!--时间节点注意一下-->
                    <p slot="description" v-if="applyStatus==='EXCHANGE_GOODS_FINISH'">{{repairsLogs[5].createDate || ''}}</p>
                </a-step>
            </a-steps>
        </div>
        <br>
        <br>
        <br>
        <br>
        <!-- 换货商品 -->
        <a-table :columns="columns" :data-source="goodsOrder" bordered rowKey="key">
            <template slot="title">换货商品</template>
            <template slot="footer">
                <div class="tableFooter">
                    <div v-if="goodsOrder.length>0">
                        <div  >商品总额：{{ totalPrice ? (totalPrice/100).toFixed(2) : '0.00'}}元</div>
                        <div  >优惠： {{ goodsOrder[0].discountPrice ? (goodsOrder[0].discountPrice/100).toFixed(2) : '0.00' }}元</div>
                        <div  >运费： {{ goodsOrder[0].freightPrice ? (goodsOrder[0].freightPrice/100).toFixed(2) : '0.00' }}元</div>
                        <div  style="color: red;font-weight: bold;">实付： {{ goodsOrder[0].goodsPrice ? (goodsOrder[0].goodsPrice/100).toFixed(2) : '0.00' }}元 +{{goodsOrder[0].integralNum || 0 }}积分</div>
                    </div>
                </div>
            </template>
        </a-table>
        <div class="info-title">服务单信息</div>
        <div>
            <!-- 订单信息 -->
            <a-descriptions bordered :size="size">
                <a-descriptions-item :span="4">
                    <template slot="label">服务单号<span style="margin-left: 28px"></span></template>
                    <div style="width: 800px">{{serveNum}}</div>
                </a-descriptions-item>

                <a-descriptions-item :span="4">
                    <template slot="label">申请状态</template>
                    <div style="width: 800px">{{applyStatusResult}}</div>
                </a-descriptions-item>

                <a-descriptions-item label="订单编号" :span="4">
                    <div style="width: 800px">{{orderNum}}</div>
                </a-descriptions-item>

                <a-descriptions-item label="申请时间" :span="4">
                    <div style="width: 800px">{{applyTime}}</div>
                </a-descriptions-item>

                <a-descriptions-item label="用户账号" :span="4">
                    <div style="width: 800px">{{userAccount}}</div>
                </a-descriptions-item>

                <a-descriptions-item label="联系人" span="3">
                    <div style="width: 800px">{{connector}}</div>
                </a-descriptions-item>

                <a-descriptions-item label="联系电话" :span="4">
                    <div style="width: 800px">{{connectorPhoneNum}}</div>
                </a-descriptions-item>

                <a-descriptions-item label="换货原因" :span="4">
                    <div style="width: 800px">{{reason}}</div>
                </a-descriptions-item>

                <a-descriptions-item label="问题描述" :span="4">
                    <div style="width: 800px">{{desc}}</div>
                </a-descriptions-item>

                <a-descriptions-item label="凭证照片" :span="4">
                    <div style="width: 800px">
                        <table-img v-for="(src,index) in imgs"
                                   :key="index"
                                   width="80px"
                                   height="80px"
                                   :src="src"/>
                    </div>
                </a-descriptions-item>

            </a-descriptions>
            <!-- 退款信息 -->
            <a-descriptions
              bordered
              style="margin-top: 20px"
              :size="size"
              :span="4"
              v-if="applyStatus!=='REVIEW_FAILED'">
                <!--里面有问题 回去再看-->
                <a-descriptions-item label="订单金额" :span="4" v-if="stepNum>=2">
                    <div style="width: 800px">￥{{(orderPrice/100).toFixed(2)}} 元 +{{ integralNum }} 积分</div>
<!--                    <div style="width: 800px" v-else>￥{{orderPrice/100}} 元 +{{ integralNum }} 积分</div>-->
                </a-descriptions-item>


            <!--    <a-descriptions-item label="退运费" :span="4" v-if="stepNum===2 &&applyStatus!=='BUYER_SEND_BACK'">
                    <div style="width: 800px">
                        <a-radio-group name="radioGroup" v-model="withdrawYF">
                            <a-radio :value="1"> 退运费</a-radio>
                            <a-radio :value="0"> 不退运费</a-radio>
                        </a-radio-group>
                    </div>
                </a-descriptions-item>-->

<!--
                <a-descriptions-item label="退运费" :span="4" v-if="stepNum>=3||applyStatus==='BUYER_SEND_BACK'">
                    <div style="width: 800px" v-if="withdrawYF===1">退运费</div>
                    <div style="width: 800px" v-if="withdrawYF===0">不退运费</div>
                </a-descriptions-item>-->


             <!--   <a-descriptions-item label="退款金额" :span="4" v-if="stepNum>=3 ||applyStatus==='BUYER_SEND_BACK'">
                    <div style="width: 800px">￥{{finalTK}}元</div>
                </a-descriptions-item>-->


            <!--    <a-descriptions-item :span="4" v-if="stepNum===2 &&applyStatus!=='BUYER_SEND_BACK'">
                    <template slot="label">确认退款金额</template>
                    <div style="width: 800px">
                        <a-input prefix="￥" style="width: 150px" v-model="finalTK" suffix="元" disabled/>
                    </div>
                </a-descriptions-item>-->


                <a-descriptions-item label="换货物流" :span="4" v-if="stepNum>=4">
                    <div style="width: 800px">{{expressCompanyName}}</div>
                </a-descriptions-item>

                <a-descriptions-item label="换货物流单号" :span="4" v-if="stepNum>=4">
                    <div style="width: 800px">{{expressTrackNumber}}</div>

                </a-descriptions-item>

                <a-descriptions-item label="收货人姓名" :span="4" v-if="stepNum>=3 && applyStatus!=='REVIEW_FAILED' && applyStatus!=='USER_CANCEL'">
                    <div style="width: 800px">{{receiver}}</div>

                </a-descriptions-item>
                <!--收获点是什么怎么填-->
                <a-descriptions-item label="选择收货点" :span="4" v-if="stepNum===2">
                    <div style="width: 800px" v-if="addressList.length>0">
                        <a-select
                          :default-value="addressList[0].fullAddress"
                          style="width: 300px"
                          @change="handleChange"
                        >
                            <a-select-option v-for="(item,index) in addressList" :key="index" :value="item.id">
                                {{item.fullAddress}}
                            </a-select-option>
                        </a-select>
                    </div>
                </a-descriptions-item>

                <a-descriptions-item label="收货人姓名" :span="4" v-if="stepNum===2">
                    <div style="width: 800px">
                        <a-input style="width: 300px" placeholder="收货人" disabled v-model="receiver"/>
                    </div>
                </a-descriptions-item>

                <a-descriptions-item label="收货地址" :span="4" v-if="stepNum>=3">
                    <div  style="width: 800px">{{address}}</div>
                    <div style="width: 800px">{{goodsAddr}}</div>
                </a-descriptions-item>
                <!--地址三级联动-->
                <a-descriptions-item label="所在区域" :span="4" v-if="stepNum===2">
                    <div style="width: 800px">
                        <a-input style="width: 300px" placeholder="省/市/区/街道" disabled v-model="PCD"/>
                    </div>
                </a-descriptions-item>

                <a-descriptions-item label="详细地址" :span="4" v-if="stepNum===2">
                    <div style="width: 800px">
                        <a-input v-model="detailAddress" style="width: 300px" disabled placeholder="详细地址信息，如道路、门牌号、小区、楼栋号、单元等信息"/>
                    </div>
                </a-descriptions-item>

                <a-descriptions-item label="联系电话" :span="4">
                    <div style="width: 800px" v-if="stepNum===2">
                        <a-input style="width: 300px" placeholder="收货人号码" v-model="receiverNumber" disabled/>
                    </div>
                    <div v-if="stepNum>=3">
                        {{receiverNumber}}
                    </div>
                </a-descriptions-item>

            </a-descriptions>

            <!--处理 备注 -->
            <a-descriptions
              bordered
              style="margin-top: 20px"
              :size="size">
                <a-descriptions-item :span="4"
                                     v-if="stepNum>=3||applyStatus==='REVIEW_FAILED'||applyStatus==='BUYER_SEND_BACK'">
                    <template slot="label">处理人员<span style="margin-left: 28px"></span></template>
                    <div style="width: 800px">{{handler}}</div>
                </a-descriptions-item>

                <a-descriptions-item label="处理时间" :span="4"
                                     v-if=" stepNum>=3||applyStatus==='REVIEW_FAILED'||applyStatus==='BUYER_SEND_BACK'">
                    <div style="width: 800px">{{repairsLogs[1].createDate}}</div>
                </a-descriptions-item>

                <a-descriptions-item label="处理备注" :span="4"
                                     v-if="stepNum>=3||applyStatus==='REVIEW_FAILED'||applyStatus==='BUYER_SEND_BACK' ">
                    <div style="width: 800px">
                        {{operationNote}}
                    </div>
                </a-descriptions-item>

                <a-descriptions-item label="处理备注" :span="4" v-if="stepNum===2 && applyStatus!=='REVIEW_FAILED'&&applyStatus!=='BUYER_SEND_BACK' && applyStatus!=='USER_CANCEL' ">
                    <div style="width: 620px">
                        <a-textarea v-model="operationNote"
                                    style="width: 620px"
                                    placeholder="处理备注"
                                    :auto-size="{ minRows: 2, maxRows: 6 }"/>
                    </div>
                </a-descriptions-item>
            </a-descriptions>
            <!-- 收货备注 -->
            <a-descriptions
              bordered
              style="margin-top: 20px"
              :size="size">

                <a-descriptions-item :span="4" v-if="stepNum>=5">
                    <template slot="label">收货人员<span style="margin-left: 28px"></span></template>
                    <div style="width: 800px">{{handler}}</div>
                </a-descriptions-item>

                <a-descriptions-item label="收货时间" :span="4" v-if="stepNum>=5">
                    <div style="width: 800px">{{repairsLogs[3].createDate}}</div>
                </a-descriptions-item>

                <a-descriptions-item label="收货备注" :span="4" v-if="stepNum===4 &&applyStatus!=='REVIEW_FAILED'">
                    <div style="width: 620px">
                        <a-textarea v-model="shouhuoexplanation"
                                    style="width: 333px"
                                    placeholder="收货备注"
                                    :auto-size="{ minRows: 2, maxRows: 6 }"/>
                    </div>
                </a-descriptions-item>

                <a-descriptions-item label="收货备注" :span="4" v-if="stepNum>=5">
                    <div style="width: 620px">
                        {{shouhuoexplanation}}
                    </div>
                </a-descriptions-item>

            </a-descriptions>

            <a-descriptions
              bordered
              style="margin-top: 20px"
              :size="size">


                <a-descriptions-item :span="4" v-if="stepNum===5">
                    <template slot="label">发货快递<span style="margin-left: 28px"></span></template>
                   <div style="width: 800px">
                       <a-select
                         style="width: 333px;"
                         :options="expressList"
                         placeholder="请选择"
                         v-model="againExpressCompanyId"
                         @change="handleChangeQuotationAttr"
                       ></a-select>
                   </div>
                </a-descriptions-item>

            <!--    <a-descriptions-item label="发货快递" :span="4" v-if="stepNum>5">
                    <div style="width: 800px">{{againExpressCompanyname}}</div>
                </a-descriptions-item>-->

                <a-descriptions-item label="发货单号" :span="4" v-if="stepNum===5 &&applyStatus!=='REVIEW_FAILED'">
                    <div style="width: 800px">
                        <a-input v-model="againExpressTrackNumber"
                                    style="width: 333px"
                                    placeholder="发货单号"
                                    />
                    </div>
                </a-descriptions-item>

                <a-descriptions-item label="发货单号" :span="4" v-if="stepNum>5">
                    <div style="width: 800px">{{againExpressTrackNumber}}</div>
                </a-descriptions-item>

                <a-descriptions-item label="发货备注" :span="4" v-if="stepNum===5 &&applyStatus!=='REVIEW_FAILED'">
                    <div style="width: 800px">
                        <a-textarea v-model="fahuoexplanation"
                                    style="width: 333px"
                                    placeholder="发货备注"
                                    :auto-size="{ minRows: 2, maxRows: 6 }"/>
                    </div>
                </a-descriptions-item>

                <a-descriptions-item label="发货备注" :span="4" v-if="stepNum>5">
                    <div style="width: 800px">
                        {{fahuoexplanation}}
                    </div>
                </a-descriptions-item>

            </a-descriptions>
        </div>
        <div class="footerBtn">
            <a-button type="primary" @click="confirmTK" v-if="stepNum ===2&&applyStatus!=='BUYER_SEND_BACK' &&applyStatus!=='USER_CANCEL'"> 确认换货</a-button>
            <a-button type="danger" class="twoBtn" @click="refuseTK" v-if="stepNum ===2&&applyStatus!=='BUYER_SEND_BACK' &&applyStatus!=='USER_CANCEL' " > 拒绝换货</a-button>
            <a-button type="primary" @click="confirmSH" v-if="stepNum ===4 && applyStatus!=='REVIEW_FAILED'"> 确认收货</a-button>
            <a-button type="primary" @click="fahuoAgain" v-if="stepNum ===5 && applyStatus==='RECEIVED_GOODS'"> 再次发货</a-button>
        </div>
    </div>
</template>

<script>
    export default {
        name: "",
        components: {},
        directives: {},
        filters: {},
        mixins: [],
        model: {},
        props: {},
        data() {
            return {
                id: this.$route.query.id,
                size: 'middle',
                goodsOrder: [],
                cityOptions: [],
                columns: [
                    {
                        title: "商品图片",
                        dataIndex: "goodsImg",
                        key: 'goodsImg',
                        align: "center",
                        customRender: (text, row) => {
                            console.log("text", text);
                            return <table-img src={text.split(',')[0]}/>;
                        },
                    },
                    {
                        title: "商品名称",
                        dataIndex: "goodsName",
                        key: 'goodsName'
                    },
                    {
                        title: "商品类型",
                        dataIndex: "goodsType",
                        key: 'goodsType',
                        align: "center",
                        customRender:(text,record)=>{
                            return text ===1 ?'定制品':'标品'
                        }
                    },
                    // 大概率要改成积分与money的组合
                    {
                        title: "价格",
                        dataIndex: "paymentWay",
                        key: "paymentWay",
                        align: "center",
                        customRender: (text, row) => {
                            // console.log("text", text);
                            switch (text) {
                                case 1:
                                    return (row.goodsPrice / 100).toFixed(2)+ "元"+"+"+ row.integralNum + "积分"
                                case 2:
                                    if (row.integralNum ==null){
                                        return (row.goodsPrice / 100).toFixed(2) +"元"  +"+"+ 0 + "积分"
                                    }else {
                                        return (row.goodsPrice / 100).toFixed(2) +"元"  +"+"+ row.integralNum + "积分"
                                    }

                              // case 3:

                            }
                        }

                    },
                    {
                        title: "ERP编号",
                        dataIndex: "erpCode",
                        key: 'erpCode'
                    },
                    {
                        title: "属性",
                        dataIndex: "skuName",
                        key: "skuName"
                    },
                    {
                        title: "数量",
                        dataIndex: "goodsNum",
                        key: "goodsNum",
                        align: "center"
                    },
                    {
                        title: "小计",
                        dataIndex: "sum",
                        key: 'sum',
                        customRender: (text, row) => {
                            console.log('row', row);
                            return "￥:".concat(((row.goodsNum * row.goodsPrice)/100).toFixed(2)+'元')
                        },
                    },
                ],
                // 步骤条默认2 后续根据处理状态改变
                stepNum: 2,
                // 换货单号
                serveNum: '',
                // 申请状态英文
                applyStatus: '',
                //申请状态中文
                applyStatusResult: '',
                // 订单编号:
                orderNum: '',
                // 申请时间
                applyTime: '',
                // 用户账号
                userAccount: '',
                // 联系人(退方)
                connector: '',
                // 退方联系人电话
                connectorPhoneNum: '',
                // 退款原因
                reason: '',
                // 原因描述
                desc: '',
                // 凭证照片
                imgs: [],
                // 订单金额
                orderPrice: '',
                // 积分数量
                integralNum:0,
                //时间节点集合
                repairsLogs:[],
                // 优惠金额
                // 实际付款金额
                //运费
                //默认退运费
                // withdrawYF: 1,
                //默认同意换货
                // isAgree: 0,
                // 卖家同意退多少钱
                // finalTK: '',
                // 换货的收货点列表
                addressList: [],
                // 具体收货点
                address: '',
                // 收货人
                receiver: '',
                // 收货人电话
                receiverNumber: '',
                // 所在地区
                province: "",
                provinceCode: "",
                city: '',
                cityCode: '',
                area: "",
                areaCode: "",
                // 省市区合集
                PCD:'',
                // 详细地址
                detailAddress: '',
                // 换货物流
                expressCompanyName: '',
                // 换货单号
                expressTrackNumber: '',
                //
                handler: "" || this.$store.state.userInfo.userName,
                // 同意退款或者拒绝退款的处理时间
                // handleTime: [],
                // 处理备注
                operationNote: '',
                // 收货备注
                shouhuoexplanation: '',
                //收货时间
                // refundTime: '',
                goodsUserName:'',
                goodsAddr:'',

                fahuoexplanation:'',       // 重发货备注
                againExpressTrackNumber:'',// 重发货物流单号
                againExpressCompanyId:'',  // 重发货快递公司id
                againExpressCompanyname:'',// 重发货选择的快递公司中文名
                expressList: [],           // 全部快递公司列表
                orderGoodsId:''            // 重发货时候发给后端的订单号
            };
        },
        computed: {

            totalPrice() {
                return this.goodsOrder.reduce((pre, cur) => {
                    return pre += cur.goodsPrice * cur.goodsNum
                }, 0)
            }

        },
        watch: {
            againExpressCompanyId(pre,cur){
                //
                console.log(pre)
                console.log(cur)
                // againExpressCompanyname
              let a =   this.expressList.filter((item,index)=>{
                  return item.value == pre
                })
                // console.log(a)
                if (a.length>0){
                    this.againExpressCompanyname = a[0].label
                }
            }

        },
        beforeCreate() {

        },

        async created() {
            console.log(this.$store.state.userInfo)
            await this.accquireUserInfo()
            await this.accquireAddress()
            await this.getExpressCompanyList()

        },

        // 方法集合
        methods: {
            async accquireUserInfo() {
                // const res = await this.$get(`/swap/order?id=${this.id}`)
                const res = await this.$get('goldenhome/gh/integral/mall/admin_/swap/order/id',{
                   id:this.id
                })
                // const res = await this.$get(`/order/goodsrepairs/query?id=${this.id}`)
                if (res && res.returnCode === 1000) {
                    console.log('换货订单信息:', res)

                    this.serveNum = res.dataInfo.id
                    let gr = res.dataInfo.goodsOrder
                    gr.paymentWay = res.dataInfo.paymentWay
                    gr.integralNum = res.dataInfo.integralNum
                    this.goodsOrder = [gr]
                    console.log(this.goodsOrder)
                    this.orderGoodsId = res.dataInfo.goodsOrder.id
                    // console.log('this.goodsOrder',this.goodsOrder)
                    this.applyStatus = res.dataInfo.swapGoodsStatus
                    console.log("状态" , this.applyStatus)

                    this.orderNum = res.dataInfo.orderNo

                    this.applyTime = res.dataInfo.createDate

                    // this.userAccount = res.dataInfo.orderGoodsRepairs.userPhone
                    // this.userAccount = res.dataInfo.phone
                    this.userAccount = res.dataInfo.userPhone

                    // this.connector = res.dataInfo.orderGoodsRepairs.userName
                    // this.connector = res.dataInfo.contactName
                    this.connector = res.dataInfo.userName

                    // this.connectorPhoneNum = res.dataInfo.orderGoodsRepairs.userPhone
                    this.connectorPhoneNum = res.dataInfo.phone


                    this.desc = res.dataInfo.reasonDesc || ''

                    this.reason = res.dataInfo.reason || ''

                    // 这里可能不止就一个金额 可能还有积分
                    // this.orderPrice = res.dataInfo.orderGoods.goodsOrderPrice
                    this.orderPrice = res.dataInfo.orderPrice
                    this.integralNum = res.dataInfo.integralNum ==null?0:res.dataInfo.integralNum

                    // 处理备注
                    // this.operationNote = res.dataInfo.orderGoodsRepairs.repairsNote
                    this.operationNote = res.dataInfo.auditorOpinion

                    //收货备注
                    this.shouhuoexplanation = res.dataInfo.takeGoodsRemark
                    this.handler = res.dataInfo.auditorName

                    // 收货人 goodsUserName
                    this.goodsUserName = res.dataInfo.goodsUserName
                    // 收货地点 goodsAddr
                    this.goodsAddr = res.dataInfo.goodsAddr
                    //detailAddress 用户详细地址
                    // this.detailAddress = res.dataInfo.detailAddress
                    //

                    //

                    //

                    // this.imgs = res.dataInfo.orderGoodsRepairs.imgs.split(',')
                    this.imgs = res.dataInfo.imgs.split(',')

                    // this.handleTime = res.dataInfo.repairsLog.createDateList[1] ||''
                    // this.handleTime = res.dataInfo.repairsLog.createDateList
                    // this.refundTime =  res.dataInfo.orderGoodsRepairs.refundTime
                    // this.finalTK = res.dataInfo.orderGoodsRepairs.refundPrice /100

                    // this.expressCompanyName = res.dataInfo.repairsLog.expressCompanyName
                    this.expressCompanyName = res.dataInfo.expressCompanyName
                    // this.expressTrackNumber = res.dataInfo.repairsLog.expressTrackNumber
                    this.expressTrackNumber = res.dataInfo.expressTrackNumber

                    // this.repairsLogs = res.dataInfo.repairsLogs
                    this.repairsLogs = res.dataInfo.orderAuditList
                    console.log('---',this.repairsLogs)
                    // console.log(this.operationNote, this.handleTime)
                    // 重新发货 快递公司 快递单号  发货备注
                    this.againExpressTrackNumber = res.dataInfo.againExpressTrackNumber
                    this.againExpressCompanyId = res.dataInfo.againExpressCompanyId
                    this.againExpressCompanyname = res.dataInfo.againExpressCompanyname
                    this.fahuoexplanation = res.dataInfo.resendRemark

                    this.applyStatusResult = this.changeApplyStatus()
                    this.changeInitStepNum()
                }
            },

            changeApplyStatus() {
                switch (this.applyStatus) {
                    case 'TO_AUDIT':
                        return '待处理'

                    case 'APPROVE_AUDIT':
                        return '同意换货等待买家寄回'

                    case 'USER_CANCEL':
                        return '已撤销申请'

                    case 'BUYER_SEND_BACK':
                        return '买家寄回途中'

                    case 'RECEIVED_GOODS':
                        return '卖家已收货等待卖家重新发货'
                    case 'AGAIN_DELIVER_GOODS':
                        return '卖家已重新发货'

                    case 'EXCHANGE_GOODS_FINISH':
                        return '换货成功'
                    case 'REVIEW_FAILED':
                        return '已拒绝'
                }
            },
            changeInitStepNum() {

                switch (this.applyStatus) {
                  // 注意空格之后要去掉
                    case 'TO_AUDIT':
                        this.stepNum = 2
                        return
                    case 'APPROVE_AUDIT':
                        this.stepNum = 3
                        return

                    case'USER_CANCEL':
                        this.stepNum = 2
                        return

                    case 'BUYER_SEND_BACK':
                        this.stepNum = 4
                        return
                    case 'RECEIVED_GOODS':
                        this.stepNum = 5
                        return
                    case 'REVIEW_FAILED':
                        this.stepNum = 3
                        return
                    case 'AGAIN_DELIVER_GOODS':
                        this.stepNum = 6
                        return
                    case 'EXCHANGE_GOODS_FINISH':
                        this.stepNum = 6
                        return
                }
            },
            // 允许换货
            async confirmTK() {
                // 调退款成功的接口  后改变处理状态
                let params = {

                    // isAgree: this.isAgree,
                    // 退不退运费 以及退款金额
                    // isRefundFare: this.withdrawYF,
                    // refundPrice: this.finalTK*100,

                    id: this.serveNum,
                    provinceCode:this.provinceCode,
                    cityCode:this.cityCode,
                    districtCode:this.areaCode,
                    provinceName:this.province,
                    cityName:this.city,
                    districtName:this.area,

                    goodsUserName:this.receiver,
                    //全地址
                    goodsAddr:this.address,
                    detailAddress:this.detailAddress,
                    merchantsPhone:this.receiverNumber,
                    // 审核意见
                    auditorOpinion:this.operationNote,
                    swapGoodsStatus:"APPROVE_AUDIT"
                }
                console.log(params)
                const res = await this.$post('goldenhome/gh/integral/mall/admin_/swap/order/update', {
                ...params
                }).catch(() => {})
                console.log('确认换货')
                console.log(res)
                await this.accquireUserInfo()
            },

            //拒绝换货
            async refuseTK() {
                // this.isAgree = 1
                let params={
                    id: this.serveNum,
                    // isAgree: this.isAgree,
                    // 拒绝换货审核意见
                    auditorOpinion: this.operationNote ,
                    swapGoodsStatus:'REVIEW_FAILED'

                }
                console.log("拒绝换货参数",params)
                //改变处理状态 调拒绝退款的接口
                const res = await this.$post('goldenhome/gh/integral/mall/admin_/swap/order/update', {
                    ...params
                })
                console.log('拒绝退款',res)
                await this.accquireUserInfo()

            },
            //
            async confirmSH() {
                console.log('确认收货')
                const res = await this.$post('goldenhome/gh/integral/mall/admin_/swap/order/update',{
                    id:this.serveNum,
                    // 收货备注
                    // goodsUserName:this.receiver,
                    takeGoodsRemark:this.shouhuoexplanation,
                    swapGoodsStatus:'RECEIVED_GOODS'
                }).catch(() => {})
                console.log('确认收货',res)
                await this.accquireUserInfo()
            },
            // 再次发货
            async fahuoAgain() {
                console.log('再次发货')
                if (!this.againExpressCompanyId){
                    return  this.$message.error("请选择快递快递公司")
                }
                if (!this.againExpressTrackNumber){
                    return  this.$message.error("单号不能为空")
                }

                if (!this.fahuoexplanation){
                    return  this.$message.error("备注不能为空")
                }

                let params = {
                    id:this.serveNum,
                    // 重新寄回物流单号
                    orderGoodsId:this.orderGoodsId,
                    againExpressCompanyId:this.againExpressCompanyId,
                    againExpressTrackNumber:this.againExpressTrackNumber,
                    // 重新寄回物流公司名称
                    againExpressCompanyname:this.againExpressCompanyname,
                    //重新发货备注
                    resendRemark:this.fahuoexplanation,
                    swapGoodsStatus:'AGAIN_DELIVER_GOODS'
                }
                console.log(params)
                const res = await this.$post('goldenhome/gh/integral/mall/admin_/swap/order/update',{
                    ...params
                }).catch(() => {})
                console.log('再次发货',res)
                await this.accquireUserInfo()
            },
            // 获取地址
            async accquireAddress() {
                const res = await this.$get('/address/config/page')
                console.log('换货地址:',res)
                // 省市区+详细地址
                this.addressList = res.dataInfo.records.filter((item,index)=>{
                    return item.addressType===1
                })
                this.province =  this.addressList[0].province
                this.provinceCode =this.addressList[0].provinceCode
                this.city = this.addressList[0].city
                this.cityCode =this.addressList[0].cityCode
                this.area = this.addressList[0].area
                this.areaCode = this.addressList[0].areaCode
                this.PCD =this.province+this.city+ this.area
                this.detailAddress =this.addressList[0].address

                this.receiver = this.addressList[0].contactName
                this.receiverNumber = this.addressList[0].phone
                console.log( this.receiverNumber)
                this.address = this.addressList[0].fullAddress
                console.log(this.addressList)

            },
            // address 是每个换货地址的id
            handleChange(id) {
                // console.log(id)  这个id就是value值
                // 根据换货地址字符串找出换货的地址对象
                let addObj = this.addressList.filter((item)=>{
                    return item.id === id
                })
                console.log(addObj)
                this.province =  addObj[0].province
                this.provinceCode =addObj[0].provinceCode
                this.city = addObj[0].city
                this.cityCode =addObj[0].cityCode
                this.area = addObj[0].area
                this.areaCode = addObj[0].areaCode
                this.PCD = ""+this.province + this.city + this.area
                this.detailAddress =addObj[0].address

                this.receiver = addObj[0].contactName
                this.receiverNumber = addObj[0].phone
                this.address = addObj[0].fullAddress
                // console.log(address,this.a)
            },

            getExpressCompanyList() {
                let url = "/express/company/list";
                this.$get(url).then((res) => {
                    if (res && res.returnCode === 1000) {
                        console.log(res, "快递公司");
                        this.expressList = res.dataInfo.map((item) => {
                            return {
                                label: item.expressCompanyName,
                                value: item.id,
                            };
                        });
                    }
                });
            },

            handleChangeQuotationAttr() {},






        },
    };
</script>
<style rel='stylesheet/less' lang='less' scoped>
    //@import url();
    .orderInfo {
        .back {
            width: 100%;
            display: flex;
            justify-content: flex-end;
            margin-bottom: 20px;
        }

        .speedProgress {
            width: 90%;
        }

        .tableFooter {
            display: flex;
            justify-content: flex-end;
        }

        .footerBtn {
            margin-top: 20px;
            display: flex;
            justify-content: center;

            .twoBtn {
                margin: 0 20px;
            }
        }

        .info-title {
            font-size: 14px;
            height: 40px;
            background: #f5f5f5;
            border-radius: 4px;
            line-height: 40px;
            padding-left: 30px;
            position: relative;
            margin: 20px 0;

            &::before {
                content: "";
                display: inline-block;
                width: 3px;
                height: 16px;
                background: #016bff;
                border-radius: 2px;
                position: absolute;
                top: 12px;
                left: 20px;
            }

            &.title2,
            &.title3 {
                margin-top: 30px;
            }
        }

    }
</style>
